#!/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@File: DealSqlUntil.py
@Author: lijk34925 
@Date: 2024/9/13 9:39
@desc: 请补充本模块功能说明
"""
from sqlglot import *


class DealSqlUntil:
    def __init__(self):
        self.sql = ""
        self.tool = parse

    @staticmethod
    def parser_sql(sql_text):
        tree = parse(sql_text)
        print(tree)

    @staticmethod
    def transpile_sql(sql_text, dialect="oracle"):
        transformed_sql = transpile(sql_text, write=dialect)
        print(transformed_sql)

    @staticmethod
    def parser_one_sql(sql_text):
        tree = parse_one(sql_text)
        print(tree)
        print(tree.args.keys())
        print(tree.args.values())
        print("this:", tree.args.get("this"))
        print("expression:", tree.args.get("expression"))
        print("expression:", tree.args.get("expressions"))




if __name__ == '__main__':
    DS = DealSqlUntil()
    sql = "SELECT * FROM users WHERE age > 30"
    # DS.parser_sql(sql)
    sql2 = "SELECT * FROM users WHERE age > 30 AND city = 'New York'"
    sql3 = """INSERT INTO hsfund.fnd_agency (agency_no,agency_name,agency_english_name,agency_type,ta_no,institution_full_name,contact_address,zip_code,contact_name,cont_tel,fax_number,email_address,bank_code,bank_account,bank_account_name,record_date,is_supported_share_detail,is_supported_share_type,max_allot_sub_discount,max_redeem_discount,redeem_cleardays,allot_cleardays,bonus_cleardays,sub_interest_days,is_supported_step_tran_in,is_supported_acc_assigned,confirm_no,contrast_bill_type,is_supported_multi_trade,api_version,interface_mode,fund_transfer_confirm_type,sub_pay_ratio,allot_pay_ratio,institution_type,remarks,attachment_no_list,updating_time) VALUES
	 ('HS003','恒生子公司','HUNDSUN3','0','HS','恒生子公司',NULL,' ',' ',' ',NULL,' ',NULL,' ',NULL,0,' ',' ',0.00000,0.00000,0,0,0,0,' ',' ',' ',' ',' ',' ',' ',' ',0.00000,0.00000,' ','HS001 UITEST','[]','2024-07-02 13:36:50')"""
    # DS.transpile_sql(sql3)
    DS.parser_one_sql(sql3)